#include "myserver.h"
#include "mythread.h"
#include "global.h"

MyServer::MyServer(QObject *parent):
    QTcpServer(parent)
{

}

void MyServer::incomingConnection(qintptr socketDescriptor)
{
    MyThread *aThread = new MyThread(socketDescriptor,this);
    connect(aThread,&MyThread::updateListItem,this,&MyServer::updateListItem);
    connect(aThread,&MyThread::closeThread,this,&MyServer::onCloseThread);
    aThread->start();
}

void MyServer::onUpdateListItem()
{
    emit updateListItem();
}

void MyServer::onCloseThread(MyThread *thread)
{
    thread->terminate();
}

